
//
//  SSTabBarController.swift
//  weibo
//
//  Created by 邵帅 on 16/6/23.
//  Copyright © 2016年 groupNineObject. All rights reserved.
//

import UIKit

class SSTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewController(SSHomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(SSMessageViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(SSFindViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(SSSettingViewController(), title: "设置", imageName: "tabbar_profile")
        
        // KVC为只读属性赋值
        let myTabBar = SSTabBar()
        myTabBar.tintColor = UIColor.orangeColor()
        
        setValue(myTabBar, forKey: "tabBar")
        
        myTabBar.closure = {
            
            let compose = SSComposeView()
            
            compose.show()
            compose.viewControlelr = self
            
            self.view .addSubview(compose)
            
        }
    }
    
    func addChildViewController(childController: UIViewController, title : String, imageName : String) {
        
        childController.tabBarItem = SSTabBarItem()
        childController.title = title
        childController.tabBarItem.title = title
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageName)_highlighted")
        
        addChildViewController(UINavigationController(rootViewController: childController))
        
    }
    

}

